package com.example.service.impl;

import com.example.entity.Job;
import com.example.entity.example.JobExample;
import com.example.mapper.JobMapper;
import com.example.service.JobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JobServiceImpl implements JobService {
    @Autowired(required = false)
    JobMapper jobMapper;

    @Override
    public List<Job> getByExampleWithLimit(JobExample example, Integer curPage, Integer pageSize) {
        int begin = (curPage - 1) * pageSize;
        return jobMapper.selectByExampleWithLimit(example, begin, pageSize);
    }

    @Override
    public long getCountByExample(JobExample example) {
        return jobMapper.countByExample(example);
    }

    @Override
    public void addJob(Job job) {
        jobMapper.insert(job);
    }

    @Override
    public String getNameById(Integer jobId) {
        return jobMapper.selectByPrimaryKey(jobId).getJname();
    }

    @Override
    public void removeById(Integer id) {
        jobMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void updateById(Job job) {
        jobMapper.updateByPrimaryKey(job);
    }
}
